from datetime import datetime

from performance_monitor import PerformanceMonitor


def run_performance_monitor(device_name, duration, interval_time):
    """
    开启性能监控
    :param device_name: 设备名称
    :param duration: 持续时间
    :param interval_time: 每次间隔
    :return:
    """
    HOST = '192.168.1.98'
    PORT = "23"
    USER = "root\n"
    PASSWORD = "vp202401\n"
    COMMAND = "/vpfile/usbfs1/get_system_usage.sh\n"
    monitor = PerformanceMonitor(host=HOST, port=PORT, user=USER, password=PASSWORD, command=COMMAND,
                                 filename='system_usage.xlsx',
                                 sheet_name=datetime.now().strftime(f'{device_name}_%Y-%m-%d'))
    monitor.collect_and_save_data(duration, interval_time)


if __name__ == '__main__':
    run_performance_monitor('NQ10-1', 900, 5)
